import { Component } from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { NzMessageService } from 'ng-zorro-antd/message';
import { SysTenantEditComponent } from './edit/edit.component';
import { SListComponent } from '../../common/list/slist.component';
import { SysTenant } from '@api/sys/model/sysTenant.model';
import { SysTenantService } from '@api/sys/service/sysTenant.service';

@Component({
  selector: 'app-sys-tenant',
  templateUrl: '../../common/list/list.component.html',
})
export class SysTenantComponent extends SListComponent<SysTenant, String> {
  constructor(
    public http: _HttpClient,
    public modal: ModalHelper,
    public sysTenantService: SysTenantService,
    public msgSrv: NzMessageService,
  ) {
    super(http, modal, sysTenantService, msgSrv, SysTenantEditComponent);
    this.searchSchema = {
      properties: {
        name: {
          type: 'string',
          title: '名称',
        },
      },
    };

    this.columns = [
      { title: 'ID', index: 'id', type: 'checkbox' },
      { title: '代码', index: 'code' },
      { title: '名称', index: 'name' },
      { title: '描述', index: 'description' },
      {
        title: '是否有效',
        index: 'enabled',
        type: 'yn',
        yn: { truth: 1 },
      },
      {
        title: '操作',
        width: 100,
        buttons: [
          // { text: '查看', click: (item: any) => `/form/${item.id}` },
          { icon: 'edit', type: 'static', modal: { component: SysTenantEditComponent }, click: 'reload', tooltip: `编辑` },
          {
            tooltip: `删除`,
            icon: 'delete',
            type: 'del',
            pop: {
              title: '是否确定删除?',
              okType: 'danger',
              icon: 'star',
            },
            click: (record, _modal, comp) => this.delete(record, _modal, comp),
          },
        ],
      },
    ];
  }
}
